<!--
* description: 基础数据--预约容量查询
* author:shensai
* createdDate: 2021.1.21
-->
<template>
  <div class="app-container app-container-table">
    <one-table-template
      ref="multipleTable"
      :dynamic-buttons="tableButtons"
      :dynamic-components="tableComponents"
      :dynamic-api-config="apiConfig"
      :dynamic-table-cols="tableCols"
      :dynamic-form-fields="formField"
      :dynamic-is-show-select="false"
      :dynamic-is-show-more-btn="false"
    />

    <edit
      v-if="editPopupsVisible"
      :key="editPopupsKey"
      :popups-visible="editPopupsVisible"
      :data-for-form="editRowData"
      :popups-state="editPopupsState"
      @close="close"
    />
  </div>
</template>
<script>
import { oneTableWithViewTemplateMixins } from "@/components/mixins/oneTableWithViewTemplateMixins";
import OneTableTemplate from "@/components/templates/oneTable";
import edit from "./edit";
import { custApi } from "@/api/se/customerManagement.js";
import Vue from "vue";

export default {
  name: "Customerelationshipquery",
  components: {
    OneTableTemplate,
    edit,
  },
  mixins: [oneTableWithViewTemplateMixins],
  // 阻塞路由预加载网格中组件的数据
  beforeRouteEnter(to, from, next) {
    Vue.prototype.$ConfigCache.CacheConfig.initData(
      [to.path, "supplierMessage-edit"],
      () => {
        next();
      }
    );
  },

  data() {
    // 页面标识（与上面beforeRouteEnter中的对应）
    const viewPageCode = this.$route.path;
    // 绑定事件配置化事件
    this.$ConfigCache.CacheConfig.bindEvent(this, [viewPageCode]);
    return {
      titleName: "",
      editRowData: {},
      editPopupsState: "",
      editPopupsVisible: false,
      // 网格查询API配置对象
      apiConfig: custApi.shortageAuditQuery,
      // 动态组件-按钮
      tableButtons: [
        {
          compKey: "btnKey5",
          size: "small",
          clickEvent: (index) => this.edit(),
          text: "预约容量设置",
          position: "right",
        },
        {
          compKey: "btnKey1",
          type: "primary",
          size: "small",
          clickEvent: () => this.queryTable(1),
          text: this.$t("sys.button.query"),
          position: "right",
          fuzzySearch: true,
        },
        {
          compKey: "btnKey4",
          size: "small",
          name: "reset",
          clickEvent: () => this.reset(),
          text: this.$t("sys.button.reset"),
          position: "right", // 重置
        },
      ],
      // 动态组件-查询条件
      tableComponents:
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path] &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path]
          .tableComponents &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path]
          .tableComponents.length > 0
          ? this.$ConfigCache.CacheConfig.cacheData[this.$route.path]
              .tableComponents
          : [
              // 显示组件
              {
                compKey: "compKey1",
                labelName: "门店编码：",
                codeField: "dlrCode",
                isMul: false,
                component: () => import("@/components/org/commonInput"),
                type: "inputText",
                isMust: true,
              },
              {
                compKey: "compKey2",
                labelName: "日期：",
                codeField: "notifyDateStart,notifyDateEnd",
                component: () =>
                  import("@/components/org/datePicker/datePicker"),
                dateType: "daterange",
                isMul: false,
                isMust: true,
              },
            ],
      // 动态生成网格列
      tableCols:
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path] &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols
          .length > 0
          ? this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols
          : [
              {
                prop: "dlrCode",
                label: "门店编码",
              },
              {
                prop: "enableDate",
                label: "日期",
              },
              {
                prop: "timeQuantum1",
                label: "0:00-1:00",
              },
              {
                prop: "timeQuantum2",
                label: "1:00-2:00",
              },
              {
                prop: "timeQuantum3",
                label: "2:00-3:00",
              },
              {
                prop: "timeQuantum4",
                label: "3:00-4:00",
              },
              {
                prop: "timeQuantum5",
                label: "4:00-5:00",
              },
              {
                prop: "timeQuantum6",
                label: "5:00-6:00",
              },
              {
                prop: "timeQuantum7",
                label: "6:00-7:00",
              },
              {
                prop: "timeQuantum8",
                label: "7:00-8:00",
              },
              {
                prop: "timeQuantum9",
                label: "8:00-9:00",
              },
              {
                prop: "timeQuantum10",
                label: "9:00-10:00",
              },
              {
                prop: "timeQuantum11",
                label: "10:00-11:00",
              },
              {
                prop: "timeQuantum12",
                label: "11:00-12:00",
              },
              {
                prop: "timeQuantum13",
                label: "12:00-13:00",
              },
              {
                prop: "timeQuantum14",
                label: "13:00-14:00",
              },
              {
                prop: "timeQuantum15",
                label: "14:00-15:00",
              },
              {
                prop: "timeQuantum16",
                label: "15:00-16:00",
              },
              {
                prop: "timeQuantum17",
                label: "16:00-17:00",
              },
              {
                prop: "timeQuantum18",
                label: "17:00-18:00",
              },
              {
                prop: "timeQuantum19",
                label: "18:00-19:00",
              },
              {
                prop: "timeQuantum20",
                label: "19:00-20:00",
              },
              {
                prop: "timeQuantum21",
                label: "20:00-21:00",
              },
              {
                prop: "timeQuantum22",
                label: "21:00-22:00",
              },
              {
                prop: "timeQuantum23",
                label: "22:00-23:00",
              },
              {
                prop: "timeQuantum24",
                label: "23:00-24:00",
              },
            ],
      formField: {
        dlrCode: "",
        appointmentStartDate: "",
        appointmentEndDate: "",
      },
      resetDialogKey: false,
    };
  },
  mounted() {
    this.queryTable(1);
  },
  methods: {
    edit() {
      this.editPopupsVisible = true;
    },
    close() {
      this.editPopupsVisible = false;
    },
  },
};
</script>

<style style lang="scss" scoped>
/deep/.el-range-editor::after {
  width: 0px;
}
</style>